import torch

a = torch.tensor([1, 2, 3], dtype=torch.float32)
print(a)

b = torch.zeros((2, 3))
print(b)

c = torch.ones((2, 3))
print(c)

d = torch.randn((2, 3))
print(d)

print(a.shape)
print(a.dtype)
print(a.device)
print(a.requires_grad)

x = torch.tensor([1.0, 2.0, 3.0])
y = torch.tensor([3.0, 2.0, 1.0])

print(x + y)
print(x * y)
print(torch.dot(x, y))

x = torch.tensor([1.0, 2.0, 3.0], device="cuda")
print(x.device)

w = torch.tensor([2.0], requires_grad=True)
y = w ** 2 + 3 * w
y.backward()
print(w.grad)
